<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;
use kartik\popover\PopoverX;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\GeneralocrSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = 'Generalocrs';
$this->params['breadcrumbs'][] = $this->title;
$this->params['breadcrumbs'][] = ['label' => '我的案卷', 'url' => ['/yue-juan/scan']];
$this->params['breadcrumbs'][] = ['label' => '上传图片', 'url' => ['/yue-juan/index']];

?>
<div class="generalocr-index">
    <?php // echo $this->render('_search', ['model' => $searchModel]); ?>
    <p>
        <?= Html::a('Create Generalocr', ['create'], ['class' => 'btn btn-success']) ?>
    </p>

    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],
            'id',
            'title',
            [
                'attribute' => 'filename',
                'format' => 'raw',
                'value' => function ($model) {
//                    return Html::a($model->filename, $model->path, ['title' => Html::img($model->path)]);
                    return PopoverX::widget([
                        'header' => '原图',
                        'type' => PopoverX::TYPE_DEFAULT,
                        'placement' => PopoverX::ALIGN_BOTTOM,
                        'content' => Html::img($model->path),
                        'toggleButton' => ['label' => Html::img($model->path, ['height' => '50px']), 'class' => 'btn btn-default'],
                    ]);
                }
            ],
//            'path',
//            'ocr_ret:ntext',
//            'ocr_string:ntext',
            [
                'attribute' => 'cor_string',
                'value' => function ($model) {
                    return mb_strcut($model->ocr_string, 0, 90);
                }
            ],
            'user_id',
            'created_at',
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>

</div>
